package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.SendApiService;
import com.yixun.qfbao.apidto.SendReqDto;
import com.yixun.qfbao.apidto.SendPremisesListResDto;
import com.yixun.qfbao.constants.OpenApiConstant;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.SendReqVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 恒信 定时推送 楼盘信息查询
 * @author liuqi
 */
@Service
public class SendPremisesListHander extends CommonAbstractHander {

    private static final Logger logger = LoggerFactory.getLogger(SendPremisesListHander.class);

    @Autowired
    private SendApiService sendApiService;

    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        SendReqVo req = (SendReqVo)reqDto;
        SendReqDto reqDto1 = req.getParams();
        BaseResponseDTO<SendPremisesListResDto> res = new BaseResponseDTO<SendPremisesListResDto>();
        SendPremisesListResDto resDto = new SendPremisesListResDto();
        try {
            resDto = sendApiService.sendPremisesList(reqDto1);
        } catch (Exception e) {
            resDto.setResponseCode(OpenApiConstant.RC_EXCEPTION_ERROR.getResponseCode());
            resDto.setResponseMessage(e.getMessage());
            logger.error("定时推送,楼盘信息异常:{}", e);
        }
        res.setResult(resDto.getResponseCode());
        res.setResData(resDto);
        return res;
    }
}
